package com.lingyu.jsjx.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lingyu.jsjx.domain.UserDocument;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lingyu.jsjx.mapper.DocumentFavoriteMapper;
import com.lingyu.jsjx.domain.DocumentFavorite;
import com.lingyu.jsjx.service.IDocumentFavoriteService;

/**
 * 收藏
Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-31
 */
@Service
public class DocumentFavoriteServiceImpl extends ServiceImpl<DocumentFavoriteMapper, DocumentFavorite> implements IDocumentFavoriteService
{
    @Autowired
    private DocumentFavoriteMapper documentFavoriteMapper;

    /**
     * 查询收藏
     * 
     * @param favoriteId 收藏主键
     * @return 收藏
     */
    @Override
    public DocumentFavorite selectDocumentFavoriteByFavoriteId(Long favoriteId)
    {
        return documentFavoriteMapper.selectDocumentFavoriteByFavoriteId(favoriteId);
    }

    /**
     * 查询收藏列表
     * @return 收藏集合
     */
    @Override
    @DataScope(deptAlias = "u", userAlias = "df",type = "jsjx")
    public List<DocumentFavorite> selectDocumentFavoriteList(UserDocument userDocument)
    {
        return documentFavoriteMapper.selectDocumentFavoriteList(userDocument);
    }

    /**
     * 新增收藏
     * 
     * @param documentFavorite 收藏
     * @return 结果
     */
    @Override
    public int insertDocumentFavorite(DocumentFavorite documentFavorite)
    {
        documentFavorite.setCreateTime(DateUtils.getNowDate());
        return documentFavoriteMapper.insertDocumentFavorite(documentFavorite);
    }

    /**
     * 修改收藏
     * 
     * @param documentFavorite 收藏
     * @return 结果
     */
    @Override
    public int updateDocumentFavorite(DocumentFavorite documentFavorite)
    {
        documentFavorite.setUpdateTime(DateUtils.getNowDate());
        return documentFavoriteMapper.updateDocumentFavorite(documentFavorite);
    }

    /**
     * 批量删除收藏
     * 
     * @param favoriteIds 需要删除的收藏主键
     * @return 结果
     */
    @Override
    public int deleteDocumentFavoriteByFavoriteIds(Long[] favoriteIds)
    {
        return documentFavoriteMapper.deleteDocumentFavoriteByFavoriteIds(favoriteIds);
    }

    /**
     * 删除收藏信息
     * 
     * @param favoriteId 收藏主键
     * @return 结果
     */
    @Override
    public int deleteDocumentFavoriteByFavoriteId(Long favoriteId)
    {
        return documentFavoriteMapper.deleteDocumentFavoriteByFavoriteId(favoriteId);
    }
}
